<?php
require_once("./DButil.php");

$courseId=$_REQUEST["courseId"];
$teacherId=$_REQUEST["teacherId"];
$status=$_REQUEST["status"];

if(isset($courseId) && strlen(trim($courseId)) && ($courseId!=0)){
    $whereSql .= " where v.courseId = {$courseId} ";
    $count=1;
}

if ($count) {
    if(isset($teacherId) && strlen(trim($teacherId)) && ($teacherId!=0)){
        $whereSql .= " and v.teacherId = {$teacherId} ";
    }
}else{
    if(isset($teacherId) && strlen(trim($teacherId)) && ($teacherId!=0)){
        $whereSql .= " where v.teacherId = {$teacherId}";
        $count=1;
    }
}


if ($count) {
    if(isset($status) && strlen(trim($status)) && ($status!=-2)){
        $whereSql .= " and v.status = '{$status}'";
    }
}else{
    if(isset($status) && strlen(trim($status)) && ($status!=-2)){
        $whereSql .= " where v.status = '{$status}'";
    }
}

$sql="select v.videoId,v.videoInfo,c.courseName,t.teacherName,v.status
from t_video v
left join t_teacher t on v.teacherId=t.teacherId
left join t_course c on v.courseId=c.courseId".$whereSql;

if (query($sql)) {
    $result=query($sql);
}
else{
$result = [
    "msg" => "未存在",
    "code" => 404,
    "success" => true,
];
}

header("Content-Type:application/json;charset=utf-8");
echo json_encode($result);
?>